class Solution 
{
public:
    string minWindow(string s, string t) 
    {
        int hash[128] = { 0 };
        int kids = 0;
        for(auto & c : t)
            if(hash[c]++ == 0) kids++; 
        int minlen = INT_MAX, begin = -1;
        int hash1[128] = { 0 };
        for(int left = 0, right = 0, count = 0; right < s.size(); right++)
        {
            char in = s[right];
            if(++hash1[in] == hash[in]) count++;
            while(count == kids)
            {
                if(right - left + 1 < minlen)
                {
                    minlen = right - left + 1;
                    begin = left;
                }
                char out = s[left++];
                if(hash1[out]-- == hash[out]) count-- ;
            }
        }
        if(begin == -1)
        return "";
        else
        return s.substr(begin, minlen);
    }
};


//   滑动窗口  +  哈希表    最小覆盖子串